﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using JKF.BusinessLayer;
using JKF.BusinessLayer.BLL;
using JKF.Entities;
using JKF.Entities.Model;
using JKF.Substructure;
using SFWS.XHandler.Core;

namespace JKF.HandlerLayer.Sales
{
    public class Sales_ContractHandler : AHttpHandler
    {
        public override void ProcessRequest()
        {
            try
            {
                this.HandleRequest(Utils.GetActionName);
            }
            catch (Exception ex)
            {
                //将错误抛到客户端(以Json格式)
                Utils.ToClient(true, ex.Message);
                AppLogger.Log(ex.Message, ex);  //写日志
            }
        }

        #region Manager
        private static bllPRODUCT productManager = new bllPRODUCT();
        private static bllCUSTOMER customerMgr = new bllCUSTOMER();
        private static bllSALES_CONTRACT salesContractMgr = new bllSALES_CONTRACT();
        private static StringBuilder builder = new StringBuilder();
        #endregion

        #region Handlers

        [Exp2Client]
        public void BarCodeExist()
        {
            var ctCode = P("barCode");
            var item = salesContractMgr.GetListArray(string.Format(" BAR_CODE='{0}'", ctCode));
            Response.Write(new ResponseInf
                {
                    Success = true,
                    Data = (item != null && item.Count > 0) ? 1 : 0
                }.ToJson());
        }

        [Exp2Client]
        public void ContractCodeExist()
        {
            var ctCode = P("contractCode");
            var item = salesContractMgr.GetListArray(string.Format(" CONTRACT_CODE='{0}'", ctCode));
            Response.Write(new ResponseInf
            {
                Success = true,
                Data = (item != null && item.Count > 0) ? 1 : 0
            }.ToJson());
        }

        /// <summary>
        /// 编辑销售合同
        /// </summary>
        [Exp2Client]
        public void EditSalesContract()
        {
            var opSuccess = false;
            var bEdit = false;
            var salesContractJson = JsonSerializer.Deserialize<ContractInfo>(P("salesConsume"));
            var contract = BuildSalesContract(salesContractJson);
            if (salesContractJson.CONTRACT_KEY.IsGuidB())
            {//Edit
                bEdit = true;
                contract.CONTRACT_KEY = salesContractJson.CONTRACT_KEY.ToGuid();
                var serverModel = salesContractMgr.GetModel(contract.CONTRACT_KEY);
                if (serverModel == null || (serverModel.STATUS == "9")) throw new Exception("待编辑项不存在.");
                //Do Update operation
                opSuccess = bllSALES_CONTRACT.UpdateSalesContract(contract);
                var customer = customerMgr.GetModel(contract.CUSTOMER_KEY);
                if (customer == null) throw new Exception("顾客不存在.");
                AppendLog(customer, serverModel, contract, LogType.Edit);
            }
            else
            {
                //Add new
                contract.CONTRACT_KEY = DB.HR.GetNewGuid().ToGuid();
                contract.POINT_KEY = Guid.Empty;
                contract.USER_CREATE = bllSYS_USER.CurrentUser.USER_KEY;
                contract.STATUS = "1";
                contract.SHOP_CODE = bllSYS_USER.CurrentUser.SHOP_CODE;
                contract.UNIQUE_CODE = bllSALES_CONTRACT.GetSalesContractUniqueCode(contract.SHOP_CODE);

                var outInfo = new STOCK_OUTinfo
                {
                    OUT_KEY = DB.HR.GetNewGuid().ToGuid(),
                    PRODUCT_KEY = contract.PRODUCT_KEY,
                    PRODUCT_NUMS = 1,
                    SHOP_CODE = contract.SHOP_CODE,
                    USER_CREATE = contract.USER_CREATE,
                    OUT_NO = string.Format("{0}{1}", contract.SHOP_CODE, DateTime.Now.ToString("yyyyMMddHHmmss")),
                    DATE_CREATE = DateTime.Now,
                    DATE_OUT = DateTime.Now,
                    DATE_UPDATE = DateTime.Now
                };

                var point = new POINT_LOGinfo()
                                {
                                    POINT_KEY = DB.HR.GetNewGuid().ToGuid(),
                                    POINT_VALUE = contract.ADD_POINT.HasValue ? contract.ADD_POINT : 0,
                                    CODE = "01"
                                };
                opSuccess = bllSALES_CONTRACT.InsertSalesContract(contract, outInfo, point);
                var customer = customerMgr.GetModel(contract.CUSTOMER_KEY);
                if (customer == null) throw new Exception("顾客不存在.");
                AppendLog(customer, contract, null, LogType.Add);
            }

            if (opSuccess)
            {
                //重新获取数据
                contract = salesContractMgr.GetModel(contract.CONTRACT_KEY);
                var customer = customerMgr.GetModel(contract.CUSTOMER_KEY);
                var product = productManager.GetModel(contract.PRODUCT_KEY);
                Response.Write(new ResponseInf
                {
                    Success = true,
                    Data = new
                    {
                        CONTRACT_KEY = contract.CONTRACT_KEY.ToString(),
                        UNIQUE_CODE = contract.UNIQUE_CODE,
                        CARD_NO = customer != null ? customer.CARD_NO : "",
                        CUSTOMER_NAME = customer != null ? customer.NAME : "",
                        MOBILE = customer != null ? customer.MOBILE : "",
                        PHONE = customer != null ? customer.PHONE : "",
                        CONTRACT_CODE = contract.CONTRACT_CODE,
                        PRODUCT_NAME = product != null ? product.NAME : "",
                        PRICE = contract.PRICE.ToString(),
                        MONEY = contract.MONEY.ToString(),
                        MODEL = product != null ? product.MODEL : "",
                        BURNDATE = contract.DATE_PRODUCED.ToShortDateLineFormat(),
                        DATE_PURCHASE = contract.DATE_PURCHASE.HasValue ? contract.DATE_PURCHASE.Value.ToString("yyyy-MM-dd") : "",
                        CLOSING_DATE = contract.CLOSING_DATE.HasValue ? contract.CLOSING_DATE.Value.ToString("yyyy-MM-dd") : "",
                        REPAIR_TERM = contract.REPAIR_TERM.ToString(),
                        STATUS = "有效",
                        OPERATOR = bllSYS_USER.CurrentUser.REAL_NAME,
                        DATE_CREATE = contract.DATE_CREATE.ToString("yyyy-MM-dd"),
                        DATE_PRODUCED = contract.DATE_PRODUCED.ToString("yyyy-MM-dd")
                    }
                }.ToJson());
                return;
            }
            throw new Exception("添加销售合同失败.");
        }

        /// <summary>
        /// 获得顾客购买记录View
        /// </summary>
        [Exp2Client]
        public void GetContractByCustomer()
        {
            var customerKey = P("customerKey");
            if (!customerKey.IsGuidB()) throw new Exception("顾客编号格式不正确.");

            Response.Write(new ResponseInf
            {
                Success = true,
                Data = (from a in bllSALES_CONTRACT.GetCustomerSalesContract(customerKey, bllSYS_USER.CurrentUser.USER_KEY.ToString()).AsEnumerable()
                        select new
                            {
                                CONTRACT_KEY = a.Field<Guid>("CONTRACT_KEY").ToString(),
                                UNIQUE_CODE = a.Field<string>("UNIQUE_CODE"),
                                CARD_NO = a.Field<string>("CUSTOMER_CARD_NO"),
                                CUSTOMER_NAME = a.Field<string>("CUSTOMER_NAME"),
                                MOBILE = a.Field<string>("CUSTOMER_MOBILE"),
                                PHONE = a.Field<string>("CUSTOMER_PHONE"),
                                CONTRACT_CODE = a.Field<string>("CONTRACT_CODE"),
                                PRODUCT_NAME = a.Field<string>("PRODUCT_NAME"),
                                PRICE = a.Field<decimal?>("PRICE").ToString(),
                                MONEY = a.Field<decimal>("MONEY"),
                                MODEL = a.Field<string>("MODEL"),
                                BURNDATE = a.Field<DateTime?>("DATE_PRODUCED").ToShortDateLineFormat(),
                                DATE_PURCHASE = a.Field<DateTime?>("DATE_PURCHASE").ToShortDateLineFormat(),
                                CLOSING_DATE = a.Field<DateTime?>("CLOSING_DATE").ToShortDateLineFormat(),
                                REPAIR_TERM = a.Field<int?>("REPAIR_TERM").ToStringNoValue(),
                                STATUS = a.Field<string>("STATUS"),
                                //EDITSHOW = a.Field<int>("isLock") > 0 ? "none" : "",
                                OPERATOR = a.Field<string>("OPERATOR"),
                                DATE_CREATE = a.Field<DateTime>("DATE_CREATE").ToShortDateString(),
                                DATE_PRODUCED = a.Field<DateTime?>("DATE_PRODUCED").ToShortDateLineFormat()
                            }).ToList()
            }.ToJson());
        }

        /// <summary>
        /// 删除销售合同
        /// </summary>
        [Exp2Client]
        public void RemoveSalesContract()
        {
            var contractKey = P("constractKey");
            if (!contractKey.IsGuidB()) throw new Exception("销售合同编号格式不正确.");
            var dbModule = salesContractMgr.GetModel(contractKey.ToGuid());
            if (dbModule == null) throw new Exception("待删除的销售合同不存在.");
            var rslt = bllSALES_CONTRACT.RemoveSalesContract(contractKey);

            var customer = customerMgr.GetModel(dbModule.CUSTOMER_KEY);
            AppendLog(customer, dbModule, null, LogType.Delete);

            Response.Write(new ResponseInf
            {
                Success = (rslt == 1),
                Message = (rslt == 0) ? "删除销售合同失败." : ""
            }.ToJson());
        }

        /// <summary>
        /// 查询销售合同
        /// </summary>
        public void GetContractByPage()
        {
            var obj = new PagerList();
            var pageCount = 0;
            var rowCount = 0;
            var pageCurrent = 0;
            var pageSize = 20;
            var schPara = JsonSerializer.Deserialize<SearchOptions>(P("schOptions"));
            pageCurrent = int.TryParse(P("PageIndex"), out pageCurrent) ? pageCurrent : 0;
            pageSize = int.TryParse(P("PageSize"), out pageSize) ? pageSize : pageSize;

            var result = bllSALES_CONTRACT.GetSalesContractPaging(schPara.DATE_PURCHASESTART, schPara.DATE_PURCHASEEND, schPara.STATE,
                schPara.SHOP_CODE, schPara.filterBy, schPara.filterOperater, schPara.fiterText, bllSYS_USER.CurrentUser.USER_KEY.ToString(), pageCurrent, pageSize, ref pageCount, ref rowCount);

            if (P("isExport") != "1")
            {
                obj.Entity = null == result ? null : (from a in result.AsEnumerable()
                                                      select new
                                                      {
                                                          CONTRACT_KEY = a.Field<Guid>("CONTRACT_KEY").ToString(),
                                                          UNIQUE_CODE = a.Field<string>("UNIQUE_CODE"),
                                                          CARD_NO = a.Field<string>("CUSTOMER_CARD_NO"),
                                                          CUSTOMER_NAME = a.Field<string>("CUSTOMER_NAME"),
                                                          MOBILE = a.Field<string>("CUSTOMER_MOBILE"),
                                                          PHONE = a.Field<string>("CUSTOMER_PHONE"),
                                                          CONTRACT_CODE = a.Field<string>("CONTRACT_CODE"),
                                                          PRODUCT_NAME = a.Field<string>("PRODUCT_NAME"),
                                                          PRICE = a.Field<decimal?>("PRICE").ToString(),
                                                          MONEY = a.Field<decimal?>("MONEY").ToString(),
                                                          MODEL = a.Field<string>("MODEL"),
                                                          BURNDATE = a.Field<DateTime?>("DATE_PRODUCED").ToShortDateLineFormat(),
                                                          DATE_PURCHASE = a.Field<DateTime?>("DATE_PURCHASE").ToShortDateLineFormat(),
                                                          CLOSING_DATE = a.Field<DateTime?>("CLOSING_DATE").ToShortDateLineFormat(),
                                                          REPAIR_TERM = a.Field<int?>("REPAIR_TERM").ToStringNoValue(),
                                                          STATUS = a.Field<string>("STATUS"),
                                                          EDITSHOW = a.Field<int>("isLock") > 0 ? "none" : "",
                                                          OPERATOR = a.Field<string>("OPERATOR"),
                                                          DATE_CREATE = a.Field<DateTime>("DATE_CREATE").ToShortDateString(),
                                                          DATE_PRODUCED = a.Field<DateTime?>("DATE_PRODUCED").ToShortDateLineFormat()
                                                      }).ToList();
                obj.RowCount = rowCount;
                obj.PageCount = pageCount;
                ResponseJsonObject = obj;
            }
            else
            {
                if (result == null) return;
                IDictionary<string, string> columns = new Dictionary<string, string>();
                columns.Add("CUSTOMER_CARD_NO", "顾客卡号");
                columns.Add("CUSTOMER_NAME", "姓名");
                columns.Add("CUSTOMER_MOBILE", "手机");
                columns.Add("UNIQUE_CODE", "销售单号");
                columns.Add("CONTRACT_CODE", "合同编号");
                columns.Add("PRODUCT_NAME", "产品名称");
                columns.Add("MODEL", "型号");
                columns.Add("PRICE", "价格");
                columns.Add("MONEY", "实收金额");
                columns.Add("DATE_PRODUCED", "生产日期");
                columns.Add("DATE_CREATE", "购买日期");
                columns.Add("CLOSING_DATE", "保修截止日期");
                Excel.Export("销售合同管理", result, columns, Response, Excel.PageType.handler);
            }
        }

        /// <summary>
        /// 获得顾客的合同记录
        /// </summary>
        public void GetSalesContractByCustomer()
        {
            var customerKey = P("customerKey");
            if (!customerKey.IsGuidB()) throw new Exception("顾客编号格式不正确.");
            var obj = new PagerList();
            var pageCount = 0;
            var rowCount = 0;
            var pageCurrent = 0;
            var pageSize = 20;
            pageCurrent = int.TryParse(P("PageIndex"), out pageCurrent) ? pageCurrent : 0;
            pageSize = int.TryParse(P("PageSize"), out pageSize) ? pageSize : pageSize;

            var result = bllSALES_CONTRACT.GetSalesConstractForCustomerPaging(customerKey,
                                                                              bllSYS_USER.CurrentUser.USER_KEY.ToString(),
                                                                              pageCurrent, pageSize, ref pageCount,
                                                                              ref rowCount);

            obj.Entity = null == result ? null : (from a in result.AsEnumerable()
                                                  select new
                                                  {
                                                      CONTRACT_KEY = a.Field<Guid>("CONTRACT_KEY").ToString(),
                                                      UNIQUE_CODE = a.Field<string>("UNIQUE_CODE"),
                                                      CARD_NO = a.Field<string>("CUSTOMER_CARD_NO"),
                                                      CUSTOMER_NAME = a.Field<string>("CUSTOMER_NAME"),
                                                      MOBILE = a.Field<string>("CUSTOMER_MOBILE"),
                                                      PHONE = a.Field<string>("CUSTOMER_PHONE"),
                                                      CONTRACT_CODE = a.Field<string>("CONTRACT_CODE"),
                                                      PRODUCT_NAME = a.Field<string>("PRODUCT_NAME"),
                                                      PRICE = a.Field<decimal?>("PRICE").ToString(),
                                                      MONEY = a.Field<decimal>("MONEY"),
                                                      MODEL = a.Field<string>("MODEL"),
                                                      BURNDATE = a.Field<DateTime?>("DATE_PRODUCED").ToShortDateLineFormat(),
                                                      DATE_PURCHASE = a.Field<DateTime?>("DATE_PURCHASE").ToShortDateLineFormat(),
                                                      CLOSING_DATE = a.Field<DateTime?>("CLOSING_DATE").ToShortDateLineFormat(),
                                                      REPAIR_TERM = a.Field<int?>("REPAIR_TERM").ToStringNoValue(),
                                                      STATUS = a.Field<string>("STATUS"),
                                                      OPERATOR = a.Field<string>("OPERATOR"),
                                                      DATE_CREATE = a.Field<DateTime>("DATE_CREATE").ToShortDateString(),
                                                      DATE_PRODUCED = a.Field<DateTime?>("DATE_PRODUCED").ToShortDateLineFormat()
                                                  }).ToList();
            obj.RowCount = rowCount;
            obj.PageCount = pageCount;
            ResponseJsonObject = obj;
        }

        /// <summary>
        /// 根据保修期限以及购买日期计算保修截止日期
        /// </summary>
        [Exp2Client]
        public void GetClosingDate()
        {
            var months = P("month");
            var dateBuy = P("dateBuy");
            DateTime dtTmp;
            int imonth;
            if (!int.TryParse(months, out imonth)) throw new Exception("保修期限格式不正确.");
            var dtClosing = DateTime.TryParse(dateBuy, out dtTmp) ? dtTmp.AddMonths(imonth).ToString("yyyy-MM-dd") : "";
            Response.Write(new ResponseInf
            {
                Success = true,
                Data = dtClosing
            }.ToJson());
        }

        [Exp2Client]
        public void GetProductBySort()
        {
            var sort = P("productSort");
            var products = productManager.GetListArray(
                string.Format(" sort_key='{0}' and (shop_code in (select shop_code from sys_user_shop where user_key='{1}') or shop_code is null)",
                sort, bllSYS_USER.CurrentUser.USER_KEY));
            Response.Write(new ResponseInf
            {
                Success = true,
                Data = (from PRODUCTinfo proInfo in products
                        select new
                        {
                            name = proInfo.NAME,
                            code = proInfo.PRODUCT_KEY.ToString(),
                            model = proInfo.MODEL,
                            price = proInfo.PURCHASE_PRICE
                        }).ToList()
            }.ToJson());
        }
        #endregion

        #region Log

        private static string modeCode = "002001001";
        /// <summary>
        /// 添加销售合同部分日志
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="logType"></param>
        private void AppendLog(CUSTOMERinfo customer, SALES_CONTRACTinfo from, SALES_CONTRACTinfo to, LogType logType)
        {
            if (customer == null) return;
            if (logType == LogType.Add)
            {
                bllSYS_LOG.SaveLog(modeCode,
                    "SALES_CONTRACT",
                    from.CUSTOMER_KEY.ToString(),
                    string.Format("添加销售合同，顾客姓名:\"{0}\"  手机号:\"{1}\"", customer.NAME, customer.MOBILE),
                    "添加",
                    BusinessBase.ClientIp);
                return;
            }
            if (logType == LogType.Edit)
            {
                builder.Clear();
                builder.AppendFormat("修改销售合同，顾客姓名：\"{0}\"  手机号：\"{1}\"", customer.NAME, customer.MOBILE);
                var bChange = false;
                if (from.DATE_PURCHASE != to.DATE_PURCHASE)
                {
                    builder.AppendFormat("购买日期原值:\"{0}\"，现值:\"{1}\"", from.DATE_PURCHASE.ToFullDateTimeFormat(), to.DATE_PURCHASE.ToFullDateTimeFormat());
                    bChange = true;
                }
                if (from.PRODUCT_KEY != to.PRODUCT_KEY)
                {
                    var prodMgr = new bllPRODUCT();
                    var prodF = prodMgr.GetModel(from.PRODUCT_KEY);
                    var prodT = prodMgr.GetModel(to.PRODUCT_KEY);
                    builder.AppendFormat("产品名称原值:\"{0}\"，现值:\"{1}\"", (prodF != null ? prodF.NAME : ""), (prodT != null ? prodT.NAME : ""));
                    bChange = true;
                }
                if (from.BAR_CODE != to.BAR_CODE)
                {
                    builder.AppendFormat("产品条形码号原值:\"{0}\"，现值:\"{1}\"", from.BAR_CODE, to.BAR_CODE);
                    bChange = true;
                }
                if (from.CONTRACT_CODE != to.CONTRACT_CODE)
                {
                    builder.AppendFormat("合同编号原值:\"{0}\"，现值:\"{1}\"", from.CONTRACT_CODE, to.CONTRACT_CODE);
                    bChange = true;
                }
                if (from.PRICE != to.PRICE)
                {
                    builder.AppendFormat("产品价格原值:\"{0}\"，现值:\"{1}\"", from.PRICE, to.PRICE);
                    bChange = true;
                }
                if (from.MONEY != to.MONEY)
                {
                    builder.AppendFormat("实收金额原值:\"{0}\"，现值:\"{1}\"", from.MONEY, to.MONEY);
                    bChange = true;
                }
                if (from.DATE_PRODUCED != to.DATE_PRODUCED)
                {
                    builder.AppendFormat("生产日期原值:\"{0}\"，现值:\"{1}\"", from.DATE_PRODUCED, to.DATE_PRODUCED);
                    bChange = true;
                }
                if (from.REPAIR_TERM != to.REPAIR_TERM)
                {
                    builder.AppendFormat("保修期限原值:\"{0}\"，现值:\"{1}\"", from.REPAIR_TERM, to.REPAIR_TERM);
                    bChange = true;
                }
                if (from.CLOSING_DATE != to.CLOSING_DATE)
                {
                    builder.AppendFormat("保修截止日期原值:\"{0}\"，现值:\"{1}\"", from.CLOSING_DATE, to.CLOSING_DATE);
                    bChange = true;
                }
                if (bChange)
                {
                    bllSYS_LOG.SaveLog(modeCode,
                      "SALES_CONTRACT",
                      from.CONTRACT_KEY.ToString(),
                      builder.ToString(),
                      "修改",
                      BusinessBase.ClientIp);
                }
                return;
            }
            if (logType == LogType.Delete)
            {
                bllSYS_LOG.SaveLog(modeCode,
                      "SALES_CONTRACT",
                      from.CONTRACT_KEY.ToString(),
                      string.Format("删除销售合同，顾客姓名:\"{0}\"  手机号:\"{1}\"", customer.NAME, customer.MOBILE),
                      "删除",
                      BusinessBase.ClientIp);
            }
            /**/
        }
        #endregion

        #region EntityHelper

        /// <summary>
        /// 依据客户端对象构建Server对象
        /// </summary>
        /// <param name="contractInfo"></param>
        /// <returns></returns>
        private SALES_CONTRACTinfo BuildSalesContract(ContractInfo contractInfo)
        {
            var contract = new SALES_CONTRACTinfo();
            decimal price;
            DateTime dateTmp;
            int months;
            if (!contractInfo.PRODUCT_KEY.IsGuidB()) throw new Exception("请选择产品.");
            contract.PRODUCT_KEY = contractInfo.PRODUCT_KEY.ToGuid();
            if (!contractInfo.CUSTOMER_KEY.IsGuidB()) throw new Exception("请选择客户.");
            contract.CUSTOMER_KEY = contractInfo.CUSTOMER_KEY.ToGuid();
            if (decimal.TryParse(contractInfo.PRICE, out price)) contract.PRICE = price;
            //if (contractInfo.BAR_CODE.Length == 0) throw new Exception("请输入条形码.");
            contract.BAR_CODE = contractInfo.BAR_CODE;
            if (contractInfo.CONTRACT_CODE.Length == 0) throw new Exception("请输入合同编号.");
            contract.CONTRACT_CODE = contractInfo.CONTRACT_CODE;
            if (!DateTime.TryParse(contractInfo.DATE_PURCHASE, out dateTmp)) throw new Exception("购买日期格式不正确.");
            contract.DATE_PURCHASE = dateTmp;
            contract.MONEY = (decimal.TryParse(contractInfo.MONEY, out price)) ? price : new decimal?();
            if (!int.TryParse(contractInfo.REPAIR_TERM, out months)) throw new Exception("保修期限格式不正确.");
            contract.REPAIR_TERM = months;
            contract.CLOSING_DATE = contract.DATE_PURCHASE.Value.AddMonths(months);
            if (int.TryParse(contractInfo.ADD_POINT, out months)) contract.ADD_POINT = months;
            contract.MEMO = contractInfo.MEMO;
            contract.UNIQUE_CODE = contractInfo.UNIQUE_CODE;
            if (!DateTime.TryParse(contractInfo.DATE_PRODUCED, out dateTmp)) throw new Exception("生产日期格式不正确.");
            contract.DATE_PRODUCED = dateTmp;
            return contract;
        }

        #endregion

        #region Class
        public class SearchOptions
        {
            public string DATE_PURCHASESTART;
            public string DATE_PURCHASEEND;
            public string STATE;
            public string SHOP_CODE;
            public string filterBy;
            public string filterOperater;
            public string fiterText;
        }

        /// <summary>
        /// 客户端Json类
        /// </summary>
        public class ContractInfo
        {
            public string CONTRACT_KEY;
            public string PRODUCT_KEY;
            public string UNIQUE_CODE;
            public string CUSTOMER_KEY;
            public string PRICE;
            public string BAR_CODE;
            public string CONTRACT_CODE;
            public string DATE_PURCHASE;
            public string ADD_POINT;
            public string POINT_KEY;
            public string MONEY;
            public string REPAIR_TERM;
            public string CLOSING_DATE;
            public string MEMO;
            public string DATE_PRODUCED;
        }
        #endregion
    }
}
